package util;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import org.example.Teacher;

import java.util.List;

public class TeacherControllerHelper {
    //查
    public static List<Condition> getCondition(JSONObject req_jsonObj){
        JSONArray conditionList_jsonArray = req_jsonObj.getJSONArray("conditionList");
        List<Condition> conditionList = null;
        if (conditionList_jsonArray != null){
            conditionList = conditionList_jsonArray.toJavaList(Condition.class);
        }
        return conditionList;
    }
    //查
    public static Pagination getPagination(JSONObject req_jsonObj){
        JSONObject pagination_jsonObj = req_jsonObj.getJSONObject("pagination");
        Pagination pagination = null;
        if (pagination_jsonObj !=null){
            pagination = pagination_jsonObj.toJavaObject(Pagination.class);
        }
        return pagination;
    }
    //增
    public static Teacher getAdd(JSONObject req_jsonObj){
        JSONObject teacher_jsonArray = req_jsonObj.getJSONObject("add");
        Teacher teacher = null;
        if (teacher_jsonArray != null){
            teacher = teacher_jsonArray.toJavaObject(Teacher.class);
        }
        return teacher;
    }
    //删
    public static Teacher getDelete(JSONObject req_jsonObj){
        JSONObject teacher_jsonArray = req_jsonObj.getJSONObject("delete");
        Teacher teacher = null;
        if (teacher_jsonArray != null){
            teacher = teacher_jsonArray.toJavaObject(Teacher.class);
        }
        return teacher;
    }

    //改
    public static Teacher getUpdate(JSONObject req_jsonObj){
        JSONObject teacher_jsonArray = req_jsonObj.getJSONObject("update");
        Teacher teacher = null;
        if (teacher_jsonArray != null){
            teacher = teacher_jsonArray.toJavaObject(Teacher.class);
        }
        return teacher;
    }
}
